using System;

using Sce.PlayStation.Core;
using Sce.PlayStation.Core.Input;
using Sce.PlayStation.Core.Imaging;
using Sce.PlayStation.Core.Graphics;

using Sce.PlayStation.HighLevel.GameEngine2D;
using Sce.PlayStation.HighLevel.GameEngine2D.Base;
using Sce.PlayStation.HighLevel.Physics2D;


namespace UWSGameJame
{
	public class Game
	{
		private GameScene scene;
		private bool running;
		private int width; 
		private int height;
				
		public Game ()
		{
			init();
		}
		
		public void update()
		{
			while (running) {
				Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.Update ();

				if (Input2.GamePad0.Start.Press == true)
					running = false;
														
				Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.Render();
				Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SwapBuffers();
				Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.PostSwap();
				
				if(running == false)
				{
					Director.Terminate ();
				}
			}
		}
		
		public void init()
		{
			Director.Initialize();
   
			scene = new GameScene();		
						   
			Director.Instance.RunWithScene(scene, true);
			
			width = Director.Instance.GL.Context.GetViewport().Width;
   			height = Director.Instance.GL.Context.GetViewport().Height;
   
			running = true;
		}
		
		public bool isRunning()
		{
			return this.running;
		}
	}
}

